Hello Slack
One of the quickest ways to get started with Twilio Autopilot is to:
- Create a new Assistant
- Turn your Assistant into a Slackbot
- Customize your Assistant
Create a New Assistant
Visit the Autopilot home in your Twilio console, then:
- Click on "Create a new Assistant" to create a new Assistant
- Give your Assistant a name
- Click the red Submit button
Turn your Assistant into a Slackbot
With only three steps you can turn your Twilio Assistant into a Slackbot:
- Create a new public Slack channel
- Create new outgoing webhook integration in Slack
- Add your Assistant's custom webhook to the Slack URLs field
Let's walk through the steps you'll need to complete now.
Create a new Public Slack Channel
On the left sidebar of your Slack client, click the "circle plus sign" (highlighted below) next to the Channels header.
Set your channel to public (private channels won't work), give it a name, and click the green Create Channel button:
Create new outgoing webhook integration in Slack
An outgoing webhook Slack integration sends POST
request containing message details to a URL of your choosing. We'll use this integration to connect our Assistant with Slack.
Visit the custom integrations page for your Slack team:
https://<slack-team-name>.slack.com/apps/manage/custom-integrations
Replace <slack-team-name>
with your Slack team name to get to your custom integrations.
From this Custom Integrations page, click Outgoing Webhooks. If you don't see Outgoing Webhooks as an option, click Apps, then Browse, and search for "Outgoing Webhooks" in the search box.
On the Outgoing Webhooks page, click the green Add Configuration button.
On the Add Configuration page, click the green Add Outgoing WebHooks Integration button at the bottom of the page.
Scroll down to the section titled Integration Settings. Select the name of the public channel that you created for your bot. Leave the Trigger Words field empty (you can read more about trigger words at the bottom of this page).
Leave the URLs field blank for a moment -- we'll come right back to it.
Give your bot a Custom Name, which you'll see everytime it replies in the channel. And if you wish, choose a Custom Icon for your bot.
Add your Assistant's custom webhook to the Slack URLs field
The custom Slack webhook for your Assistant takes this form:
https://channels.autopilot.twilio.com/v1/<ACCOUNT_SID>/<ASSISTANT_SID>/slack
As you can see, you'll need two pieces of information from Twilio to complete this URL:
- Account SID
- Assistant SID
You can find your Account SID in the Twilio Console
You can find your Assistant SID in the Autopilot assistant List:
Again, here's the the URL template:
https://channels.autopilot.twilio.com/v1/<ACCOUNT_SID>/<ASSISTANT_SID>/slack
Use this URL template to:
- Replace the <ACCOUNT_SID> and <ASSISTANT_SID> with your own.
- Paste your custom URL into the URLs field in the Slack configuration screen.
- Click the green Save Settings button at the bottom of the page.
That's it! Now go back to your Assistant's Slack channel, and type "Hello!" to see what happens.
Customize your Assistant
You now have a dumb assistant that can reply with a static reply to inbound messages. Let's customize that message.
Go back to your Assistants list in the console, and click on the name of your newly created Assistant. On the left navbar, click on Task Builder.
Click on the red plus sign to create a task for your assistant. Name this task hello-world. You'll see that this task is powered by a few lines of JSON. say is a Task Action. Change the say string to a new message, then scroll to the bottom of the page and click the Save button.
And then head back over to Slack, and send your bot a new message to see your "Hello, world!" greeting
関連トピック
Now that you have a working Assistant, and an easy way to test changes you make, we recommend you check out:
ヘルプが必要ですか?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.