Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph JS
>
Tutorial
> Create chat
The following example shows you how to create a new chat.
import { GraphClient } from '../independentsoft/graph/graph.js'; import { AadUserConversationMember, Chat } from '../independentsoft/graph/teams.js'; async function mainFunc() { try { const client = new GraphClient(); client.clientId = "xxxxxxxxxx-209e-454e-xxxxxxxxxxxxxxxxxxx"; client.tenant = "independentsoft.onmicrosoft.com"; client.username = "info@independentsoft.onmicrosoft.com"; client.password = "password"; let member1 = new AadUserConversationMember(); member1.displayName = "User1"; member1.userId = "info@independentsoft.onmicrosoft.com"; member1.roles.push("owner"); let member2 = new AadUserConversationMember(); member2.displayName = "User2"; member2.userId = "rade@independentsoft.onmicrosoft.com"; member2.roles.push("owner"); let chat = new Chat(); chat.topic = "Test chat"; chat.members.push(member1); chat.members.push(member2); const createdChat = await client.createChat(chat); console.log("Chat Id: " + createdChat.id); } catch (e) { console.error(e.code) //error code console.error(e.message) //description console.error(e.date) //timestamp console.error(e.innerError) //innerError } } mainFunc();
Need help? Ask our developers:
Name*
Email*
Message*