Skip to content

Instantly share code, notes, and snippets.

View johnfischelli's full-sized avatar

John Fischelli johnfischelli

  • Twilio
View GitHub Profile
@johnfischelli
johnfischelli / plugin.js
Created August 6, 2023 01:43
PostMessage for Flex
import React from 'react';
import * as Flex from '@twilio/flex-ui';
import { FlexPlugin } from '@twilio/flex-plugin';
const PLUGIN_NAME = 'TestPlugin';
export default class TestPlugin extends FlexPlugin {
constructor() {
super(PLUGIN_NAME);
}
@johnfischelli
johnfischelli / closeChannel.js
Created February 4, 2020 23:53
A node script to mark a Twilio Flex Chat Channel as INACTIVE
const twilio = require('twilio');
const accountSid = '';
const authToken = '';
const chatService = '';
const channelSid = process.argv[2] || '';
if (channelSid === '') {
console.error('A channelSid must be provided. `node closeChannel.js <channelSid>`');
return process.exit();
@johnfischelli
johnfischelli / RedirectCall.js
Created January 15, 2020 21:18
Redirect Call to Automated Voicemail Message
import React from 'react';
import { IconButton, withTheme } from '@twilio/flex-ui';
const containerStyles = {
padding: '20px'
}
const paragraphStyles = {
marginBottom: '20px'
}
@johnfischelli
johnfischelli / App.js
Last active September 9, 2022 03:33
Flex Webchat UI Replace PreEngagment Form Example
import React from 'react';
import * as FlexWebChat from "@twilio/flex-webchat-ui";
import PreEngagementForm from './PreEngagementForm';
class App extends React.Component {
state = {};
constructor(props) {
super(props);
@johnfischelli
johnfischelli / FlextendedState.js
Created October 11, 2019 15:38
Adding a custom redux store to Flex WebChat UI
import {combineReducers} from 'redux';
import { WebchatReducer } from '@twilio/flex-webchat-ui'
const rootReducer = (function () {
const reducers = {flex: WebchatReducer };
return {
addReducer: function (slice, reducer) {
reducers[slice] = reducer;
},
combinedReducers: function () {
@johnfischelli
johnfischelli / twilio-flex-wrap-or-cancel-chat-task.js
Last active January 16, 2020 16:16
Submit a channelSid to this function and have it wrap-up or cancel the associated TaskRouter Task.
// view instructions about the twilio-flex-token-validator here: https://www.npmjs.com/package/twilio-flex-token-validator
const JWEValidator = require('twilio-flex-token-validator').functionValidator;
exports.handler = JWEValidator(async function(context, event, callback) {
// setup twilio client
const client = context.getTwilioClient();
// parse data form the incoming http request
const channelSid = event.channelSid;