Send message from Web

In previous tutorial, we prepared a Vue.js project and connected it to Amio Chat. Now, we will add some real functionality. Let's start by sending a message.

Update Component

in Chat.vue, replace the code from the previous tutorial with the code below. Remember to copy the channel ID from administration to amioChat.connect(). The new changes in the code are:

  1. Message input - Enter the message to be sent here.
  2. List of messages - Every message sent will stack up here.
  3. SendMessage() - The method handles the actual message sending. It also updates a list of messages that we have sent.
    <div id="chat">
        <p>Connected: {{connected}}</p>
      <!-- 1. Message input -->
      <form @submit.prevent="sendMessage">
          <label for="message">Message:</label>
          <input id="message" type="text" v-model="message">
        <button type="submit">Send</button>
      <!-- 2. List of messages  -->
        <template v-for="(msg, index) in messageList">
          <p :key="index">Sent message: {{msg}}</p>

import {amioChat} from 'amio-chat-sdk-web'

export default {
  data() {
    return {
      connected: false,
      messageList: [],
      message: ''
  methods: {
    // 3. Send message and update the List of messages
    sendMessage(e) {
      const messageText = this.message
        .then(() => {
      this.message = ''
  mounted() {
    // TODO Find and paste the 'channel ID' from
    amioChat.connect({channelId: '{insert your channel ID here}'})
      .then(() => {
        this.connected = true


<style scoped>
#chat {
  text-align: left;

Test it out

Start the server by running npm run serve. Then go to http://localhost:8080 and you should see that message was sent.



You can verify that Amio received the message by looking at the Logs.


What’s Next