Autopilot "Programmable Chat wrapper"
Firs things - I USE VANILLA js - now I need to have a "web based" wrapper for an autopilot (think like a web based "chat bot". I've followed examples - nothing just a not configured message, I have SID's and Secrets etc. Sorry to say but TBH overall I find the documentation on how to do this very poor and any examples I find/see "worse".
How on earth do you put autopilot into a web wrapper with vanilla JS?
Comments
-
Hi @russell_p ,
Great question! I'm a huge fan of Vanilla JS so I too was interested in this information. Can you confirm if it is Twilio’s Autopilot, our conversational bot that you're using? If you are, you can use the custom channel integration https://www.twilio.com/docs/autopilot/channels/custom-channel They can use Axios or other HTTP client to send POST request to the bot.
Here is an example https://www.twilio.com/docs/autopilot/channels/custom-channel#example-function. The sample, as it is written on Node JS, but the intention is to show how to code the POST request.
I hope this helps! ✨
-
@sbrijmohan, Hi Shivani, thanks for this, looks like I might have been a bit "stupid" - custom channel of course, now there is only 1 problem -
"Custom Channel V1 is deprecated. It will continue to work but it won't be evolved to support future functionality." and my console no longer shows the option to create one .... aghhh Do you know of any work around?
OR
would running/using a Programmable Chat webhook have the same "effect" functionality?
-
@russell_p Hi Russell,
While Custom Channel V1 is deprecated, V2 is active and available. You wouldn't need to generate a new channel before you try to send new messages to Autopilot.
I was able to send this request without specifying the endpoint in the console first.
Request (through curl)
curl -X POST 'https://channels.autopilot.twilio.com/v2/'$TWILIO_ACCOUNT_SID'/{AssistantSID}/custom/Test' \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "Text=Tell me a joke&UserId=Steven&Language=en-US" \ -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
Response (formatted):
{ "response":{ "says":[ { "speech":"Why don't skeletons ride roller coasters? They don't have the stomach for it.", "text":"Why don't skeletons ride roller coasters? They don't have the stomach for it." } ], "listen":{} }, "dialogue":{ "sid":"UK9c7e3c5f81e6467aaf48a752164759d3", "current_task":"joke", "user_identifier":"Steven", "memory":"{\"twilio\":{\"custom.Test\":{}}}" } }
Categories
- 83 All Categories
- 19 SIGNAL 2021
- 376 Product Discussions
- 7 Community - Announcements
- 2 Changelog
- 4 Forum UI Updates
- 8 Welcome Guide
- 6 Community - Events
- 2 Twilio Relay Developer Conference 2021 Mega Thread
- 1 External Community Events
- 25 Inspiration
- 17 Community - Other Discussions
- 1 Community- Twilio Startups