0

Just to try to give you an idea of what we are trying to do: we have a Python system that works like a chatbot, answering some questions automatically, but there comes a time when we need to send the contact to the service one by one, and we need to use Python to open the conversation in Flex

I tried many ways to send messages to a chat on Flex, but as I said previously we just able to create a chat no send messages into it, better saying, we’re able to send the messages but they don’t appear on Flex’s chat interface (that’s weird). I tried 1) using the normal way via API, 2) creating a Runtime function (the same result than via API, just creating a chat but no messages appearing), 3) I tried applying Twilio Sync, and also 4) I tried using Twilio Proxy directly.

I can get the sid for all objects created and see the chat created on Flex interface, but I can't see the messages sent to this chat on Flex's UI.

event = {
    'from': 'phone_number_from',
    'to': 'flex_phone_number',
    'body': 'Testing'
}

attrs = get_channel_attrs(event.get('from'))

channel = get_or_create_chat_channel(event.get('from'), event.get('to'), attrs)

print('Channel created: %s' % channel.sid)

task = get_or_create_ongoing_tasks(event.get('from'), channel.sid)

print('Task created: %s' % task.sid)

message = send_message(channel=channel, from_=event.get('from'), body=event.get('body'))

print('Message created: %s' % message.sid)

-----------------------

Channel created: CH99b4831f********************
Task created: WTe8eee516********************
Message created: IM08884be42********************


philnash
  • 70,667
  • 10
  • 60
  • 88
  • What is Flex in this case? The tag refers to Apache Flex (actionscript programming), but that's clearly not what you're using here. I'm not sure what the correct tag would be. Is it a company-specific framework? – Brian Jan 15 '19 at 22:46
  • How did you go with resolving this issue? – MagicFlow May 06 '19 at 22:25
  • @MagicFlow actually, I didn't hear back from Twilio the solution for this, I think that's kind of integration is not possible with TwilioFlex yet. – Teeh Amaral Jun 25 '19 at 15:54

2 Answers2

0

You may need to set additional attributes for the chat task to appear in Flex. Here is an example of Taskrouter attributes through the web chat and through SMS in Taskrouter. These tasks both appear in Flex.

Web chat:

{"channelSid":"CHc7221e1c8ac04b4d9f45xxxxxxxxxxxx","name":"Jane","channelType":"web"}

SMS:

{"channelSid":"CH86818963afed4d769fb3xxxxxxxxxxxx","endpoint":"sms","identity":"+15555555555","name":"+15555555555","title":"SMS request"}
Aaron A
  • 68
  • 7
  • Thanks for sharing this, but the problem is that I can see the tasks (channels) in Flex, but I can't see the messages sent to the tasks (channels). These messages I can see on Twilio Console side but not in Flex's panel. – Teeh Amaral Jan 15 '19 at 17:31
  • It's possible to see a task that is not configured to show the conversation in the chat channel. Did you check the attributes in taskrouter? If those look ok, I would suggest checking the out of the box Twilio Function called "Flex Create Chat" to see how a chat task and channel is created so it will show in flex (runtime > functions > flex create chat). It is in NodeJS, but the attributes should be the same. – Aaron A Jan 15 '19 at 22:43
  • For the taskrouter task attributes specifically, you need to have a value for "channelSid" for flex to make the connection between the task and the chat channel – Aaron A Jan 15 '19 at 23:00
  • Is there some step required to also have the agent added to the chat channel as a participant? – MagicFlow May 06 '19 at 22:26
  • The functions I referenced above applied to the preview version of flex, but it appears that with GA, flex shifted to studio flows. Since GA I have only been able to create chats in flex using the Web Chat UI https://www.twilio.com/docs/flex/installing-and-using-flex-webchat . – Aaron A May 08 '19 at 13:11
0

Aaron, I am having similar issue and was trying to have a look at Flex Create Chat function but it is not there. When I click "create a function" and filter by flex product only blan function template is provided which will generate this function code:

exports.handler = function(context, event, callback) {
    let twiml = new Twilio.twiml.VoiceResponse();
    // twiml.say("Hello World");
    callback(null, twiml);
};
Adam Bezecny
  • 195
  • 1
  • 11