> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create invitation

> How to create meeting invitations with CRMScript

<Tip>
  It is good practice to always find out when people will be available, before inviting them to a meeting by linking them to follow-ups.
</Tip>

```crmscript theme={null}
NSAppointmentAgent appointmentAgent;

// Schedule
DateTime start;
start.moveToHourStart();
start.addHour(1);
DateTime end = start;
end.addHour(1);

NSAppointmentEntity a = appointmentAgent.CreateDefaultAppointmentEntityByTypeAndAssociate(7, 1);
a.SetStartDate(start);
a.SetEndDate(end);
a.SetDescription("Sprint retrospective");

// Build list of available attendees
NSParticipantInfo[] participants;
NSAssociateAgent associateAgent;

Integer[] teamMembers;
teamMembers.pushBack(8);
teamMembers.pushBack(27);

for(Integer i = 0; i < teamMembers.length(); i++) {

  NSAppointment[] appointmentList = appointmentAgent.GetAssociateDiary(teamMembers[i], start, end, -1);

  if (appointmentList.length() == 0) {

    NSParticipantInfo p;
    p.SetAssociateId(teamMembers[i] );
    participants.pushBack(p);
  }
  else {
    printLine(associateAgent.GetAssociate(teamMembers[i]).GetFullName() + " is unavailable at the given time.");
  }
}

// Add a room
NSParticipantInfo room;
room.SetAssociateId(37);
participants.pushBack(room);

// Finalize booking
a.SetParticipants(participants);
a = appointmentAgent.SaveAppointmentEntity(a);
```

## Read more

* [Invitations][1]

[1]: ../../../../diary/learn/invitation/index


## Related topics

- [Working with follow-ups (appointments) in API](/en/diary/dev/index.md)
- [How to create an invitation (services)](/en/api/web-services/howto/diary/create-invitation-services.md)
- [appointment table](/en/database/tables/appointment.md)
- [Invitation](/en/api/archive-providers/reference/invitation.md)
- [Create And Accept](/en/api/reference/restful/agent/appointment_agent/create-and-accept.md)
- [Create Appointment For U I D](/en/api/reference/restful/agent/appointment_agent/create-appointment-for-u-i-d.md)
